<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
</head>

<body>
    <div id="app">
        <button @click="click" >点击切换图片</button>
        <br>
        <img :src="imgSrc" alt="">
    </div>
    <script>
         var app = new Vue({
            el:'#app',
            data() {
                return {
                    imgSrc:'img/1.png',
                    num:0
                }
            },
            methods:{
                click(e){
                    this.num++;
                    console.log(this.num);
                    if(this.num%2==0){
                        this.imgSrc = 'img/1.png'
                    }else if(this.num%2==1){
                        this.imgSrc = 'img/2.png'
                    }
                    
                }
            }
        })
    </script>
</body>

</html>